<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>计算属性：做缓存</title>
    <!--在线CDN-->
    <!--1.导入vue.js-->
    <script src="https://cdn.jsdelivr.net/npm/vue@2.5.21/dist/vue.min.js"></script>
</head>
<body>
<div id="app">
    <p>currentTime1:{{currentTime1()}}</p>
    <p>currentTime2:{{currentTime2}}</p>
</div>
<script type="text/javascript">
    let vm = new Vue({
        el: "#app",
        data: {
            message: "hello cqh"
        },
        methods: {
            currentTime1: function () {
                return Date.now(); //返回一个时间戳
            }
        },
        //计算属性
        computed: {
            currentTime2: function () { //计算属性，methods和computed方法不能重名，重名后只会调用methods方法。
                this.message; //mybatis缓存，message发生改变，currentTime2刷新
                return Date.now(); //返回一个时间戳
            }
        }
    });
</script>
</body>
</html>